package whf.framework.web.struts;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * 用于传送结果给终端用户，主要用途在于使用你的应用程序真正与struts解偶
 * @author wanghaifeng
 * @create Nov 22, 2006 10:27:50 PM
 * 
 */
public class WebForward {
	private ActionMapping mapping;
	
	private String forward;
	
	private String candidate;

	public WebForward(WebData data, String forward){
		this.forward = forward;
		this.mapping = data.getMapping();
	}
	
	public WebForward(WebData data, String forward, String candidate){
		this(data, forward);
		this.candidate = candidate;
	}
	/**
	 * @return Returns the candidate.
	 */
	public String getCandidate() {
		return candidate;
	}

	/**
	 * @param candidate The candidate to set.
	 */
	public void setCandidate(String candidate) {
		this.candidate = candidate;
	}

	/**
	 * @return Returns the forward.
	 */
	public String getForward() {
		return forward;
	}

	/**
	 * @param forward The forward to set.
	 */
	public void setForward(String forward) {
		this.forward = forward;
	}
	
	public ActionForward getActionForward(){
		ActionForward res = this.mapping.findForward(this.forward);
		if(res == null){
			res = this.mapping.findForward(this.candidate);
		}
		return res;
	}
}
